home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / c / flash-0.4.3.lha / flash-0.4.3 / Lib / script.h < prev    next >
C/C++ Source or Header  |  1999-02-21  |  5KB  |  152 lines

  1. #ifndef _SCRIPT_H_
  2. #define _SCRIPT_H_
  3.  
  4. // SWF file parser.
  5. //
  6. //////////////////////////////////////////////////////////////////////
  7.  
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <assert.h>
  11. #include "swf.h"
  12. #include "shape.h"
  13. #include "button.h"
  14. #include "bitmap.h"
  15. #include "font.h"
  16. #include "text.h"
  17. #include "sound.h"
  18. #include "adpcm.h"
  19. #include "program.h"
  20. #include "sprite.h"
  21.  
  22. //////////////////////////////////////////////////////////////////////
  23. // Input script object definition.
  24. //////////////////////////////////////////////////////////////////////
  25.  
  26. // An input script object.  This object represents a script created from 
  27. // an external file that is meant to be inserted into an output script.
  28. struct CInputScript  : public Dict
  29. {
  30.     // Programs
  31.     Program *programs;    // All programs
  32.     Program *program;    // Current parsed program
  33.  
  34.     //Flash info
  35.     long frameRate;
  36.     long frameCount;
  37.     Rect frameRect;
  38.  
  39.     // Pointer to file contents buffer.
  40.     U8 *m_fileBuf;
  41.  
  42.     // File state information.
  43.     U32 m_filePos;
  44.     U32 m_fileSize;
  45.     U32 m_actualSize;
  46.     U32 m_fileStart;
  47.     U16 m_fileVersion;
  48.  
  49.     // Bit Handling
  50.     S32 m_bitPos;
  51.     U32 m_bitBuf;
  52.  
  53.     // Tag parsing information.
  54.     U32 m_tagStart;
  55.     U32 m_tagEnd;
  56.     U32 m_tagLen;
  57.  
  58.     // Parsing information.
  59.     S32 m_nFillBits;
  60.     S32 m_nLineBits;
  61.     S32 m_nGlyphBits;
  62.     S32 m_nAdvanceBits;
  63.  
  64.     // Set to true if we wish to dump all contents long form
  65.     U32 m_dumpAll;
  66.  
  67.     // if set to true will dump image guts (i.e. jpeg, zlib, etc. data)
  68.     U32 m_dumpGuts;
  69.  
  70.     // Handle to output file.
  71.     FILE *m_outputFile;
  72.  
  73.     // Constructor/destructor.
  74.     CInputScript();
  75.     ~CInputScript();
  76.  
  77.     // Tag scanning methods.
  78.     U16 GetTag(void);
  79.     U8 GetByte(void);
  80.     U16 GetWord(void);
  81.     U32 GetDWord(void);
  82.     void GetRect(Rect *r);
  83.     void GetMatrix(Matrix *matrix);
  84.  
  85.     void GetCxform(Cxform *cxform, BOOL hasAlpha);
  86.     char *GetString(void);
  87.  
  88.     // Routines for reading arbitrary sized bit fields from the stream.
  89.     // Always call start bits before gettings bits and do not intermix 
  90.     // these calls with GetByte, etc...    
  91.     void InitBits();
  92.     S32 GetSBits(S32 n);
  93.     U32 GetBits(S32 n);
  94.  
  95.     // Tag subcomponent parsing methods
  96.     FillStyleDef *  ParseFillStyle(long *n, long getAlpha = 0);
  97.     LineStyleDef *  ParseLineStyle(long *n, long getAlpha = 0);
  98.     ShapeRecord  *  ParseShapeRecord(long getAlpha = 0);
  99.     ButtonRecord *  ParseButtonRecord(long getCxform = 0);
  100.     ActionRecord *  ParseActionRecord();
  101.     TextRecord   *  ParseTextRecord(int hasAlpha = 0);
  102.  
  103.     // Parsing methods.
  104.     void ParseEnd();                // 00: stagEnd
  105.     void ParseShowFrame(U32 frame, U32 offset);    // 01: stagShowFrame
  106.     void ParseDefineShape(int level);        // 02: stagDefineShape
  107.     void ParseFreeCharacter();                         // 03: stagFreeCharacter
  108.     void ParsePlaceObject();            // 04: stagPlaceObject
  109.     void ParseRemoveObject();                          // 05: stagRemoveObject
  110.     void ParseDefineBits();                            // 06: stagDefineBits
  111.     void ParseDefineButton();               //x 07: stagDefineButton
  112.     void ParseJPEGTables();                        // 08: stagJPEGTables
  113.     void ParseSetBackgroundColor();                    // 09: stagSetBackgroundColor
  114.     void ParseDefineFont();                 //x 10: stagDefineFont
  115.     void ParseDefineText(int hasAplha);            //x 11: stagDefineText    33: stagDefineText2
  116.     void ParseDoAction();                              // 12: stagDoAction    
  117.     void ParseDefineFontInfo();             //x 13: stagDefineFontInfo
  118.     void ParseDefineSound();                           // 14: stagDefineSound
  119.     void ParseStartSound();                            // 15: stagStartSound
  120.     void ParseStopSound();                             // 16: stagStopSound
  121.     void ParseDefineButtonSound();                     // 17: stagDefineButtonSound
  122.     void ParseSoundStreamHead();                        // 18: stagSoundStreamHead
  123.     void ParseSoundStreamBlock();                      // 19: stagSoundStreamBlock
  124.     void ParseDefineBitsLossless();                    // 20: stagDefineBitsLossless
  125.     void ParseDefineBitsJPEG2();                       // 21: stagDefineBitsJPEG2
  126.     void ParseDefineButtonCxform();                    // 23: stagDefineButtonCxform
  127.     void ParseProtect();                               // 24: stagProtect
  128.     void ParsePlaceObject2();                          // 26: stagPlaceObject2
  129.     void ParseRemoveObject2();                         // 28: stagRemoveObject2
  130.     void ParseDefineButton2();              //x 34: stagDefineButton2
  131.     void ParseDefineBitsJPEG3();                       // 35: stagDefineBitsJPEG3
  132.     void ParseDefineBitsLossless2();                   // 36: stagDefineBitsLossless2
  133.     void ParseDefineMouseTarget();                     // 38: stagDefineMouseTarget
  134.     void ParseDefineSprite();               //x 39: stagDefineSprite
  135.     void ParseNameCharacter();                         // 40: stagNameCharacter
  136.     void ParseFrameLabel();                            // 43: stagFrameLabel
  137.     void ParseSoundStreamHead2();                        // 45: stagSoundStreamHead2
  138.     void ParseDefineMorphShape();           //x 46: stagDefineMorphShape
  139.     void ParseDefineFont2();                //x 48: stagDefineFont2
  140.     void ParseUnknown(long,long);
  141.  
  142.     void ParseTags();
  143.     BOOL ParseData(char * data,long size);
  144.     void S_DumpImageGuts();
  145.  
  146. #ifdef DUMP
  147.     long save(char *filenam);
  148. #endif
  149. };
  150.  
  151. #endif /* _SCRIPT_H_ */
  152.